package com.xiyu.service.repository.files.certificate;

import com.xiyu.service.model.files.certificate.FilesLandOwnershipFetcher;
import com.xiyu.service.model.office.area.OfficeAreaFetcher;
import com.xiyu.service.vo.files.landOwnership.LandOwnershipPageQueryInput;
import com.xiyu.service.model.files.certificate.FilesLandOwnership;
import com.xiyu.service.model.files.certificate.FilesLandOwnershipTable;
import org.babyfish.jimmer.spring.repository.JRepository;
import org.babyfish.jimmer.Page;

public interface FilesLandOwnershipRepository extends JRepository<FilesLandOwnership, Long> {
    FilesLandOwnershipTable filesLandOwnershipTable = FilesLandOwnershipTable.$;

    default Page<FilesLandOwnership> pageQuery(LandOwnershipPageQueryInput inputVO){
        return
            sql().createQuery(filesLandOwnershipTable)
                    .where(filesLandOwnershipTable.landNo().likeIf(inputVO.getLandNo()))
                    .where(filesLandOwnershipTable.user().likeIf(inputVO.getUser()))
                    .where(filesLandOwnershipTable.remark().likeIf(inputVO.getRemark()))
                    .where(filesLandOwnershipTable.fileNo().likeIf(inputVO.getFileNo()))
                    .where(filesLandOwnershipTable.location().likeIf(inputVO.getLocation()))
                    .where(filesLandOwnershipTable.area().name().likeIf(inputVO.getAreaName()))
                    .orderBy(filesLandOwnershipTable.id().desc())
                    .select(filesLandOwnershipTable.fetch(FilesLandOwnershipFetcher.$.allTableFields().area(OfficeAreaFetcher.$.allTableFields())))
                    .fetchPage(inputVO.getPageNo() - 1, inputVO.getPageSize());

    }


}